package com.t11;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * Created by xuyiwei on 2018/7/22.
 */
class ReversibleArrayList<T> extends ArrayList<T> {
    public ReversibleArrayList(Collection<T> c) {
        super(c);
    }

    public Iterator<T> reversed() {
        return new Iterator<T>() {
            int index = size()-1;
            @Override
            public boolean hasNext() {
                return index>-1;
            }

            @Override
            public T next() {
                return get(index--);
            }
        };
    }

    public static void main(String[] args) {

    }
}

public class AdapterMethonIdiom {
}
